package IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class Bytestream{

  static String pathreadfile;
  static String pathwritefile;
private static Scanner sc;
  public static void setpathreadfile(String s){
	  pathreadfile=s;
  }
  public static void setpathwritefile(String s){
	  pathwritefile=s;
  }
  public static void readfile(String pathfile) throws IOException{
	 FileInputStream f = null;
	 try {
		f=new FileInputStream(pathfile);
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		System.out.println("not Found File");
		e.printStackTrace();
	}
	 int i;
	 do {
         i = f.read();
         if (i != -1) {
             System.out.print((char) i);
         }
     } while (i != -1);
     f.close();
  }
  public static void writefile(String pathfile) throws IOException{
	  FileOutputStream f1 = null;
	  try {
		f1=new FileOutputStream (pathfile);
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	  System.out.println("chuong trinh ghi file");
	  char i='a';
      char j ='z';
      while(i!=j) {
          f1.write(i);
          i++;
      }
	  f1.close();
  }
  
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);
		System.out.println("nhap duong dan file ban muon doc");
		setpathreadfile(sc.nextLine());
		readfile(pathreadfile);
		System.out.println("nhap dia chi ban muon ghi file");
		setpathwritefile(sc.nextLine());
		writefile(pathwritefile);
	
	}

}
